<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="Mathematica——模式规则3, 我心永恆的小站">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>Mathematica——模式规则3 | 我心永恆的小站</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>
    <link rel="stylesheet" href="/css/vs2015.css">

<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="我心永恆的小站" type="application/atom+xml">
</head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">我心永恆的小站</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">我心永恆的小站</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
    </ul>
</div>

        </div>

        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/4.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">Mathematica——模式规则3</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/%E6%95%99%E7%A8%8B/">
                                <span class="chip bg-color">教程</span>
                            </a>
                        
                            <a href="/tags/Mathematica/">
                                <span class="chip bg-color">Mathematica</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-03-25
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2020-03-31
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    2.1k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    9 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>

        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <blockquote>
<h4 id="说明"><a href="#说明" class="headerlink" title="说明"></a>说明</h4><p>最近心里总是很烦，不知道为什么，可能大学要毕业了，对未来还是很迷茫，不知道怎么办，很难受。希望以后能好起来吧。 </p>
</blockquote>
<h2 id="1-3-自带模式的内置函数"><a href="#1-3-自带模式的内置函数" class="headerlink" title="1.3 自带模式的内置函数"></a>1.3 自带模式的内置函数</h2><h3 id="1-3-1-Cases"><a href="#1-3-1-Cases" class="headerlink" title="1.3.1 Cases"></a>1.3.1 Cases</h3><p>这个函数通常用在表达式的结构上。<br>更准确地说，它用于表达式中与特定模式匹配的子表达式。<br>下面举例子说明</p>
<h4 id="Example：从列表中选择整数"><a href="#Example：从列表中选择整数" class="headerlink" title="Example：从列表中选择整数"></a>Example：从列表中选择整数</h4><pre class=" language-mathematica"><code class="language-mathematica">Clear[testlist]
testlsit={1,2,3,1.3,Pi}
Cases[testlist,_Integer]</code></pre>
<p>需要注意的是我们在这里，不需要给模式命名，以为我们不需要对结果就行任何操作。</p>
<h4 id="Example-根据条件去掉一些数字"><a href="#Example-根据条件去掉一些数字" class="headerlink" title="Example:根据条件去掉一些数字"></a>Example:根据条件去掉一些数字</h4><p>我们来考虑这么一个特殊的例子：假设我们有一组数据，我们需要去掉那些比0.3小的数字</p>
<pre class=" language-mathematica"><code class="language-mathematica">Clear[eps, data];
eps = 0.3;
data = Table[Random[], {10}];
Cases[data, x_ /; x > eps]</code></pre>
<!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre class=" language-mathematica"><code class="language-mathematica">{0.861627, 0.807515, 0.627041, 0.519299, 0.831482, 0.789996, 0.90291,
0.420605, 0.694002}</code></pre>
<h4 id="拓展功能"><a href="#拓展功能" class="headerlink" title="拓展功能"></a>拓展功能</h4><p><code>Cases</code>还有一个功能是立即对找到的结果执行一些转换。<br>语法是<strong>Cases[expr,rule,levespec,n]</strong>,和前面一样后面的两个参数是可以选择的，我们可以看到我们现在的模式是一个规则，模式是它的l.h.s (左边)。<br>比如说，现在我们想找到一个除以5余0的数字，如果余数是0就返回True，如果是不是就返回False.</p>
<pre class=" language-mathematica"><code class="language-mathematica">data1 = Table[RandomInteger[{1, 100}], {10}]
Cases[data1, x_ :> {x, Mod[x, 5] == 0}]</code></pre>
<!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{87, 22, 15, 5, 85, 71, 11, 53, 78, 59}

{{87, False}, {22, False}, {15, True}, {5, True}, {85, True}, {71, 
  False}, {11, False}, {53, False}, {78, False}, {59, False}}</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<h4 id="在一个列表中选择正数"><a href="#在一个列表中选择正数" class="headerlink" title="在一个列表中选择正数"></a>在一个列表中选择正数</h4><p>首先我们造一个列表</p>
<pre><code>Clear[list];
list = Table[RandomInteger[{-10, 10}], {15}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{-7, 5, 5, 4, -3, -3, 9, 4, 7, 10, 10, 7, 2, -6, 3}</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<p>然后用模式匹配一下就行了</p>
<pre><code>Cases[list, _?Positive]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{5, 5, 4, 9, 4, 7, 10, 10, 7, 2, 3}</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<h4 id="Example：嵌套列表的匹配"><a href="#Example：嵌套列表的匹配" class="headerlink" title="Example：嵌套列表的匹配"></a>Example：嵌套列表的匹配</h4><p>我们来考虑一个二维列表</p>
<pre><code>Clear[list];
list=Table[i+j,{i,1,4},{j,1,3}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{{2, 3, 4}, {3, 4, 5}, {4, 5, 6}, {5, 6, 7}}</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<p>假如现在我们想把所有的偶数都选择出来。<br>我们来试试看</p>
<pre><code>Cases[list,x_EvenQ]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{}</code></pre><p>很遗憾，结果不是我们想要的。<br>为什么会这样呢，因为Cases函数默认情况下是作用在第一层列表上，我们这里的第一层列表不是数字，我们列表的第二层才是数字。这里我们可以用FullForm看看看。</p>
<pre><code>list//FullForm</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>List[List[2,3,4],List[3,4,5],List[4,5,6],List[5,6,7]]</code></pre><p>所以我们应该这么做：</p>
<pre><code>Cases[list,x_?EvenQ,2]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{2, 4, 4, 4, 6, 6}</code></pre><p>这里参数2的意思是从第1层到第二层的所有偶数，我们也可以把这个限制在第二层，用 {2}</p>
<pre><code>Cases[list,x_?EvenQ,{2}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{2, 4, 4, 4, 6, 6}</code></pre><p>在这种情况下，2和{2} 并没有说明区别，但是如果现在我们想要找到的不是数字而是子列表。我们可以这样做:</p>
<pre><code>Clear[found];
Cases[list,x_List:&gt;Total[x]]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{9, 12, 15, 18}</code></pre><p>上面这个就是我们作用在子列表。<br>我们还可以对子列表施加一些条件，例如，只找到那些包含数字4的子列表:</p>
<pre><code>Cases[list,x_List/;Cases[x,4]=!={}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{{2, 3, 4}, {3, 4, 5}, {4, 5, 6}}</code></pre><p>如果说我们想搜索第二层</p>
<pre><code>Cases[list, _list, {2}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{}</code></pre><p>返回的是空值，因为第二层都是数字，没有列表。</p>
<h4 id="Example-解决奇数子列表的简单解决方法"><a href="#Example-解决奇数子列表的简单解决方法" class="headerlink" title="Example: 解决奇数子列表的简单解决方法"></a>Example: 解决奇数子列表的简单解决方法</h4><p>重新说明一下这个问题：<br>我们想要找到包含 奇数个奇数的子列表。我们曾经用很复杂的办法解决这问题的，现在我们用Cases快速解决他。<br>这里是我们的列表：</p>
<pre><code>Clear[list];
list=Range/@Range@6</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 
  5, 6}}</code></pre><h4 id="Example：列表中第一个质数"><a href="#Example：列表中第一个质数" class="headerlink" title="Example：列表中第一个质数"></a>Example：列表中第一个质数</h4><p>假设我们想要得到一组数字中的第一个给定的质数。</p>
<pre><code>list=Table[Random[Integer,{1,100}],{30}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{8, 68, 62, 58, 91, 44, 34, 17, 27, 60, 45, 59, 85, 99, 7, 49, 28, 4, 
33, 42, 45, 100, 8, 6, 18, 11, 89, 49, 48, 88}</code></pre><p>比如说我们想要挑出前3个质数</p>
<pre><code>Cases[list, _?PrimeQ, 1, 3]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{17, 59, 7}</code></pre><p>请注意，在这里我们仍然需要提供第三个参数(level specification)，尽管对于简单列表来说这通常是不需要的(默认为1)<br>这是因为，否则3的参数将被解释为一个层数，如果我们不加1这个参数，我们将得到所有的素数。你可以试一下</p>
<h4 id="为什么不使用循环？"><a href="#为什么不使用循环？" class="headerlink" title="为什么不使用循环？"></a>为什么不使用循环？</h4><p>你可能认为在上面给出的所有例子中使用循环会产生相同的结果。<br>我们为什么不使用循环呢？<br>就一句话：效率低下！我多次说明mathematica中不要使用循环，不要使用循环！</p>
<h4 id="Example-在一个有两个变量的多项式中挑选某些需要的项"><a href="#Example-在一个有两个变量的多项式中挑选某些需要的项" class="headerlink" title="Example 在一个有两个变量的多项式中挑选某些需要的项"></a>Example 在一个有两个变量的多项式中挑选某些需要的项</h4><p>我们要在(1+x)^10*(1+y)^10中挑选那些x的幂为奇数，y的幂为偶数的项。</p>
<pre><code>Clear[a,x,y];
Cases[Expand[(1+x)^10*(1+y)^10],a_*x^_?OddQ *y^_?EvenQ,Infinity]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{5400 x^3 y^2, 11340 x^5 y^2, 5400 x^7 y^2, 450 x^9 y^2, 
 25200 x^3 y^4, 52920 x^5 y^4, 25200 x^7 y^4, 2100 x^9 y^4, 
 25200 x^3 y^6, 52920 x^5 y^6, 25200 x^7 y^6, 2100 x^9 y^6, 
 5400 x^3 y^8, 11340 x^5 y^8, 5400 x^7 y^8, 450 x^9 y^8, 120 x^3 y^10,
  252 x^5 y^10, 120 x^7 y^10, 10 x^9 y^10}</code></pre><p>最后一个参数设置为无穷大意味着应该搜索表达式的所有层数，也就是把符合条件的所有层都找出来。</p>
<h3 id="1-3-2-DelectCases"><a href="#1-3-2-DelectCases" class="headerlink" title="1.3.2 DelectCases"></a>1.3.2 DelectCases</h3><p>从这个函数的名称可以清楚地看出，它从一个列表中删除了与给定模式匹配的所有元素。它的语法类似于case。<br>和Cases的区别是，Cases返回一个已找到的子表达式列表，而DeleteCases返回原始列表的(副本)，这些子表达式已被删除。</p>
<h4 id="Example-删除列表中的偶数"><a href="#Example-删除列表中的偶数" class="headerlink" title="Example :删除列表中的偶数"></a>Example :删除列表中的偶数</h4><pre><code>Clear[list];
list=Range@15;
DeleteCases[Range@15,_?OddQ]</code></pre><pre><code>{2, 4, 6, 8, 10, 12, 14}</code></pre><p>我们刚把所有奇数从列表中删除了。但list这个列表本身没有发生任何变化。<br>我们可以看看。</p>
<pre><code>list</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}</code></pre><p>在这方面，DelectCases操作与大多数Mathematica内建命令的工作方式相同，而且没有副作用:创建和修改输入变量的副本。<br>如果我们想要更改list的内容，你可以这样：</p>
<pre><code>list = DeleteCases[list, _?OddQ]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{2, 4, 6, 8, 10, 12, 14}</code></pre><p>然后你在输入list，运行就会改变list的内容了。</p>
<p>让我们执行一个时间测量:测量删除从前100000个自然数中删除那些余数除以5小于2的自然数所需要的时间:</p>
<pre><code>Timing[Short[DeleteCases[Range@100000, x _ /; Mod[x, 5] &lt;= 2]]]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{0.015625,{1,2,&lt;&lt;99996&gt;&gt;,99999,100000}}</code></pre><p>看到没有速度特别快。然我们再来看看垃圾循环。</p>
<pre><code>Module[{i, j, result, s}, 
   For[i = j = 1; s = result = Range@100000, i &lt;= 100000, i++, 
    If[Mod[s[[i]], 5] &lt;= 2, result[[j++]] = s[[i]]]]; 
   Take[result, j - 1]] // Short // AbsoluteTiming</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{0.56624,{1,2,&lt;&lt;59996&gt;&gt;,99997,100000}}</code></pre><p>很明显使用循环比Cases慢了几百倍！所以别用循环了！</p>
<h4 id="Example-非零的整数子序列"><a href="#Example-非零的整数子序列" class="headerlink" title="Example :非零的整数子序列"></a>Example :非零的整数子序列</h4><p>考虑以下问题:我们得到一个整数列表，其中一些可以是零，我们要做的是从列表中提取连续的非零元素的所有子序列。</p>
<pre><code>Clear[list]; list = Table[Random[Integer, {0, 3}], {20}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{2, 2, 1, 1, 0, 0, 2, 1, 3, 2, 0, 2, 2, 2, 2, 0, 0, 2, 0, 2}</code></pre><p>解决这个问题的第一步是使用Split，在遇到零时将元素拆分为子列表.</p>
<pre><code>step1 = Split[list, #1 != 0 &amp;]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{{2, 2, 1, 1, 0}, {0}, {2, 1, 3, 2, 0}, {2, 2, 2, 2, 0}, {0}, {2, 0}, {2}}</code></pre><p>不过，我们在子列表中得到了一些0，因此必须删除它们。</p>
<pre><code>step2 = DeleteCases[step1, 0, {2}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{{2, 2, 1, 1}, {}, {2, 1, 3, 2}, {2, 2, 2, 2}, {}, {2}, {2}}</code></pre><p>最后，前面的操作通常会从包含一个0的子列表生成一些空列表,我们现在也必须删除它们:</p>
<pre><code>step3 = DeleteCases[step2, {}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>{{2, 2, 1, 1}, {2, 1, 3, 2}, {2, 2, 2, 2}, {2}, {2}}</code></pre><p>现在我们打包起来：</p>
<pre><code>Clear[f];
f[x : {__Integer}] := 
 DeleteCases[DeleteCases[Split[x, #1 != 0 &amp;], 0, {2}], {}]</code></pre><!--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-->
<pre><code>f[list]

{{2, 2, 1, 1}, {2, 1, 3, 2}, {2, 2, 2, 2}, {2}, {2}}</code></pre>
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://wxyhgk.gitee.io" rel="external nofollow noreferrer">我心永恆</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://wxyhgk.gitee.io/mma-rulepatten3/">https://wxyhgk.gitee.io/mma-rulepatten3/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="https://wxyhgk.gitee.io" target="_blank">我心永恆</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/%E6%95%99%E7%A8%8B/">
                                    <span class="chip bg-color">教程</span>
                                </a>
                            
                                <a href="/tags/Mathematica/">
                                    <span class="chip bg-color">Mathematica</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    
    <div class="social-share" data-sites="qq,qzone,wechat,weibo,douban" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            
        </div>
    </div>

    

    

    

    

    
        <style>
    .valine-card {
        margin: 1.5rem auto;
    }

    .valine-card .card-content {
        padding: 20px 20px 5px 20px;
    }

    #vcomments textarea {
        box-sizing: border-box;
        background: url("/medias/comment_bg.png") 100% 100% no-repeat;
    }

    #vcomments p {
        margin: 2px 2px 10px;
        font-size: 1.05rem;
        line-height: 1.78rem;
    }

    #vcomments blockquote p {
        text-indent: 0.2rem;
    }

    #vcomments a {
        padding: 0 2px;
        color: #4cbf30;
        font-weight: 500;
        text-decoration: none;
    }

    #vcomments img {
        max-width: 100%;
        height: auto;
        cursor: pointer;
    }

    #vcomments ol li {
        list-style-type: decimal;
    }

    #vcomments ol,
    ul {
        display: block;
        padding-left: 2em;
        word-spacing: 0.05rem;
    }

    #vcomments ul li,
    ol li {
        display: list-item;
        line-height: 1.8rem;
        font-size: 1rem;
    }

    #vcomments ul li {
        list-style-type: disc;
    }

    #vcomments ul ul li {
        list-style-type: circle;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    #vcomments table, th, td {
        border: 0;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments h1 {
        font-size: 1.85rem;
        font-weight: bold;
        line-height: 2.2rem;
    }

    #vcomments h2 {
        font-size: 1.65rem;
        font-weight: bold;
        line-height: 1.9rem;
    }

    #vcomments h3 {
        font-size: 1.45rem;
        font-weight: bold;
        line-height: 1.7rem;
    }

    #vcomments h4 {
        font-size: 1.25rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    #vcomments h5 {
        font-size: 1.1rem;
        font-weight: bold;
        line-height: 1.4rem;
    }

    #vcomments h6 {
        font-size: 1rem;
        line-height: 1.3rem;
    }

    #vcomments p {
        font-size: 1rem;
        line-height: 1.5rem;
    }

    #vcomments hr {
        margin: 12px 0;
        border: 0;
        border-top: 1px solid #ccc;
    }

    #vcomments blockquote {
        margin: 15px 0;
        border-left: 5px solid #42b983;
        padding: 1rem 0.8rem 0.3rem 0.8rem;
        color: #666;
        background-color: rgba(66, 185, 131, .1);
    }

    #vcomments pre {
        font-family: monospace, monospace;
        padding: 1.2em;
        margin: .5em 0;
        background: #272822;
        overflow: auto;
        border-radius: 0.3em;
        tab-size: 4;
    }

    #vcomments code {
        font-family: monospace, monospace;
        padding: 1px 3px;
        font-size: 0.92rem;
        color: #e96900;
        background-color: #f8f8f8;
        border-radius: 2px;
    }

    #vcomments pre code {
        font-family: monospace, monospace;
        padding: 0;
        color: #e8eaf6;
        background-color: #272822;
    }

    #vcomments pre[class*="language-"] {
        padding: 1.2em;
        margin: .5em 0;
    }

    #vcomments code[class*="language-"],
    pre[class*="language-"] {
        color: #e8eaf6;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }

    #vcomments b,
    strong {
        font-weight: bold;
    }

    #vcomments dfn {
        font-style: italic;
    }

    #vcomments small {
        font-size: 85%;
    }

    #vcomments cite {
        font-style: normal;
    }

    #vcomments mark {
        background-color: #fcf8e3;
        padding: .2em;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }
</style>

<div class="card valine-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div id="vcomments" class="card-content" style="display: grid">
    </div>
</div>

<script src="/libs/valine/av-min.js"></script>
<script src="/libs/valine/Valine.min.js"></script>
<script>
    new Valine({
        el: '#vcomments',
        appId: '8i5IVUkUwJXeA2lmcXHA1oya-gzGzoHsz',
        appKey: '8VLP3WBVp7k20K81z9qUxg1i',
        notify: 'false' === 'true',
        verify: 'false' === 'true',
        visitor: 'true' === 'true',
        avatar: 'mm',
        pageSize: '10',
        lang: 'zh-cn',
        placeholder: 'just go go'
    });
</script>

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/latex-tikz-mindmap/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/5.jpg" class="responsive-img" alt="tizk构建思维导图">
                        
                        <span class="card-title">tizk构建思维导图</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            tizk构建思维导图首先需要调用宏包：
\usetikzlibrary{mindmap}
这个包提供了绘制思维导图的样式
1. 综述：这个宏包的目的是使思维导图的创建更容易。
每个思维导图都应该放在一个范围或一幅使用思维导图样式的图片中。此
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2020-03-31
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            我心永恆
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E6%95%99%E7%A8%8B/">
                        <span class="chip bg-color">教程</span>
                    </a>
                    
                    <a href="/tags/tikz/">
                        <span class="chip bg-color">tikz</span>
                    </a>
                    
                    <a href="/tags/tex/">
                        <span class="chip bg-color">tex</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/mma-rulepattern2/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/5.jpg" class="responsive-img" alt="Mathematica——规则模式2">
                        
                        <span class="card-title">Mathematica——规则模式2</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            1.2.5 反复应用规则——ReplaceRepeated函数由于任何给定的规则或规则列表通常只在表达式的任何元素上作用一次，所以它们不会“跟踪”由它们自己的操作导致的表达式中的更改。通过反复将规则或规则列表应用于表达式直到其停止更改，可以
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-03-20
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            我心永恆
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E6%95%99%E7%A8%8B/">
                        <span class="chip bg-color">教程</span>
                    </a>
                    
                    <a href="/tags/Mathematica/">
                        <span class="chip bg-color">Mathematica</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->


<!-- 代码块折行 -->


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('2'),
            headingSelector: 'h2, h3, h4, h5, h6'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4, h5, h6').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>



    <footer class="page-footer bg-color">
    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">2019</span>
            <a href="https://wxyhgk.gitee.io" target="_blank">我心永恆</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">43.3k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">


    <a href="mailto:3123624718@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=3123624718" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 3123624718" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







</div>
    </div>
    <script src="/js/highlight.pack.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    
    <script type="text/javascript" color="0,0,255"
        pointColor="0,0,255" opacity='0.7'
        zIndex="-1" count="99"
        src="/libs/background/canvas-nest.js"></script>
    

    

    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
